/******************************************************************************
*                                                                             *
* lfsbcr.h    LFS - 条码(BCR)定义                                             *
*                                                                             *
*             Version 1.00  (2017-06-20)                                      *
*                                                                             *
******************************************************************************/

#ifndef __INC_LFSBCR__H
#define __INC_LFSBCR__H

#ifdef __cplusplus
extern "C" {
#endif

#include <lfsapi.h>

/*   设置字节对齐方式   */
#pragma pack (push, 1)

/* LFSBCRCAPS.dev_class 取值 */

#define     LFS_SERVICE_CLASS_BCR               (15)
#define     LFS_SERVICE_CLASS_VERSION_BCR       (0x0001)
#define     LFS_SERVICE_CLASS_NAME_BCR          "BCR"

#define     BCR_SERVICE_OFFSET                  (LFS_SERVICE_CLASS_BCR * 100)

/* 信息指令 */

#define     LFS_INF_BCR_STATUS                  (BCR_SERVICE_OFFSET + 1)
#define     LFS_INF_BCR_CAPABILITIES            (BCR_SERVICE_OFFSET + 2)

/* 执行指令 */

#define     LFS_CMD_BCR_READ                    (BCR_SERVICE_OFFSET + 1)
#define     LFS_CMD_BCR_RESET                   (BCR_SERVICE_OFFSET + 2)
#define     LFS_CMD_BCR_SET_GUIDANCE_LIGHT      (BCR_SERVICE_OFFSET + 3)
#define     LFS_CMD_BCR_POWER_SAVE_CONTROL      (BCR_SERVICE_OFFSET + 4)
#define     LFS_CMD_BCR_SYNCHRONIZE_COMMAND     (BCR_SERVICE_OFFSET + 5)

/* 事件 */

#define     LFS_SRVE_BCR_DEVICEPOSITION         (BCR_SERVICE_OFFSET + 1)
#define     LFS_SRVE_BCR_POWER_SAVE_CHANGE      (BCR_SERVICE_OFFSET + 2)

/* LFSBCRSTATUS.device 取值 */

#define     LFS_BCR_DEVONLINE                   LFS_STAT_DEVONLINE
#define     LFS_BCR_DEVOFFLINE                  LFS_STAT_DEVOFFLINE
#define     LFS_BCR_DEVPOWEROFF                 LFS_STAT_DEVPOWEROFF
#define     LFS_BCR_DEVNODEVICE                 LFS_STAT_DEVNODEVICE
#define     LFS_BCR_DEVHWERROR                  LFS_STAT_DEVHWERROR
#define     LFS_BCR_DEVUSERERROR                LFS_STAT_DEVUSERERROR
#define     LFS_BCR_DEVBUSY                     LFS_STAT_DEVBUSY
//#define     LFS_BCR_DEVFRAUDATTEMPT             LFS_STAT_DEVFRAUDATTEMPT
//#define     LFS_BCR_DEVPOTENTIALFRAUD           LFS_STAT_DEVPOTENTIALFRAUD

/* LFSBCRSTATUS.bcr_scanner 取值 */

#define     LFS_BCR_SCANNERON                   (0)
#define     LFS_BCR_SCANNEROFF                  (1)
#define     LFS_BCR_SCANNERINOP                 (2)
#define     LFS_BCR_SCANNERUNKNOWN              (3)

/* LFSBCRSTATUS.device_position
LFSBCRDEVICEPOSITION.position  取值 */

#define     LFS_BCR_DEVICEINPOSITION            (0)
#define     LFS_BCR_DEVICENOTINPOSITION         (1)
#define     LFS_BCR_DEVICEPOSUNKNOWN            (2)
#define     LFS_BCR_DEVICEPOSNOTSUPP            (3)

/* LFSBCRCAPS.symbologies
LFSBCRREADINPUT.symbologies
LFSBCRREADOUTPUT.symbology 取值 */

#define     LFS_BCR_SYM_UNKNOWN                 (0)
#define     LFS_BCR_SYM_EAN128                  (1)
#define     LFS_BCR_SYM_EAN8                    (2)
#define     LFS_BCR_SYM_EAN8_2                  (3)
#define     LFS_BCR_SYM_EAN8_5                  (4)
#define     LFS_BCR_SYM_EAN13                   (5)
#define     LFS_BCR_SYM_EAN13_2                 (6)
#define     LFS_BCR_SYM_EAN13_5                 (7)
#define     LFS_BCR_SYM_JAN13                   (8)
#define     LFS_BCR_SYM_UPCA                    (9)
#define     LFS_BCR_SYM_UPCE0                   (10)
#define     LFS_BCR_SYM_UPCE0_2                 (11)
#define     LFS_BCR_SYM_UPCE0_5                 (12)
#define     LFS_BCR_SYM_UPCE1                   (13)
#define     LFS_BCR_SYM_UPCE1_2                 (14)
#define     LFS_BCR_SYM_UPCE1_5                 (15)
#define     LFS_BCR_SYM_UPCA_2                  (16)
#define     LFS_BCR_SYM_UPCA_5                  (17)
#define     LFS_BCR_SYM_CODABAR                 (18)
#define     LFS_BCR_SYM_ITF                     (19)
#define     LFS_BCR_SYM_11                      (20)
#define     LFS_BCR_SYM_39                      (21)
#define     LFS_BCR_SYM_49                      (22)
#define     LFS_BCR_SYM_93                      (23)
#define     LFS_BCR_SYM_128                     (24)
#define     LFS_BCR_SYM_MSI                     (25)
#define     LFS_BCR_SYM_PLESSEY                 (26)
#define     LFS_BCR_SYM_STD2OF5                 (27)
#define     LFS_BCR_SYM_STD2OF5_IATA            (28)
#define     LFS_BCR_SYM_PDF_417                 (29)
#define     LFS_BCR_SYM_MICROPDF_417            (30)
#define     LFS_BCR_SYM_DATAMATRIX              (31)
#define     LFS_BCR_SYM_MAXICODE                (32)
#define     LFS_BCR_SYM_CODEONE                 (33)
#define     LFS_BCR_SYM_CHANNELCODE             (34)
#define     LFS_BCR_SYM_TELEPEN_ORIGINAL        (35)
#define     LFS_BCR_SYM_TELEPEN_AIM             (36)
#define     LFS_BCR_SYM_RSS                     (37)
#define     LFS_BCR_SYM_RSS_EXPANDED            (38)
#define     LFS_BCR_SYM_RSS_RESTRICTED          (39)
#define     LFS_BCR_SYM_COMPOSITE_CODE_A        (40)
#define     LFS_BCR_SYM_COMPOSITE_CODE_B        (41)
#define     LFS_BCR_SYM_COMPOSITE_CODE_C        (42)
#define     LFS_BCR_SYM_POSICODE_A              (43)
#define     LFS_BCR_SYM_POSICODE_B              (44)
#define     LFS_BCR_SYM_TRIOPTIC_CODE_39        (45)
#define     LFS_BCR_SYM_CODABLOCK_F             (46)
#define     LFS_BCR_SYM_CODE_16K                (47)
#define     LFS_BCR_SYM_QRCODE                  (48)
#define     LFS_BCR_SYM_AZTEC                   (49)
#define     LFS_BCR_SYM_UKPOST                  (50)
#define     LFS_BCR_SYM_PLANET                  (51)
#define     LFS_BCR_SYM_POSTNET                 (52)
#define     LFS_BCR_SYM_CANADIANPOST            (53)
#define     LFS_BCR_SYM_NETHERLANDSPOST         (54)
#define     LFS_BCR_SYM_AUSTRALIANPOST          (55)
#define     LFS_BCR_SYM_JAPANESEPOST            (56)
#define     LFS_BCR_SYM_CHINESEPOST             (57)
#define     LFS_BCR_SYM_KOREANPOST              (58)

/* guid_lights 数组的大小和下标上限 */

#define LFS_BCR_GUIDLIGHTS_SIZE                 (32)
#define LFS_BCR_GUIDLIGHTS_MAX                  (LFS_BCR_GUIDLIGHTS_SIZE - 1)

/* LFSBCRSTATUS.guid_lights [...]
LFSBCRCAPS.guid_lights [...] 数组的下标
*/
#define     LFS_BCR_GUIDANCE_BCR                (0)

/* LFSBCRSTATUS.guid_lights [...]
LFSBCRCAPS.guid_lights [...],
LFSBCRSETGUIDLIGHT.guid_light 取值 */

#define     LFS_BCR_GUIDANCE_NOT_AVAILABLE      (0x00000000)
#define     LFS_BCR_GUIDANCE_OFF                (0x00000001)
#define     LFS_BCR_GUIDANCE_ON                 (0x00000002)
#define     LFS_BCR_GUIDANCE_SLOW_FLASH         (0x00000004)
#define     LFS_BCR_GUIDANCE_MEDIUM_FLASH       (0x00000008)
#define     LFS_BCR_GUIDANCE_QUICK_FLASH        (0x00000010)
#define     LFS_BCR_GUIDANCE_CONTINUOUS         (0x00000080)
#define     LFS_BCR_GUIDANCE_RED                (0x00000100)
#define     LFS_BCR_GUIDANCE_GREEN              (0x00000200)
#define     LFS_BCR_GUIDANCE_YELLOW             (0x00000400)
#define     LFS_BCR_GUIDANCE_BLUE               (0x00000800)
#define     LFS_BCR_GUIDANCE_CYAN               (0x00001000)
#define     LFS_BCR_GUIDANCE_MAGENTA            (0x00002000)
#define     LFS_BCR_GUIDANCE_WHITE              (0x00004000)
#define     LFS_BCR_GUIDANCE_ENTRY              (0x00100000)
#define     LFS_BCR_GUIDANCE_EXIT               (0x00200000)


/* LFSBCRSTATUS.anti_fraud_module 取值 */

#define     LFS_BCR_AFMNOTSUPP                  (0)
#define     LFS_BCR_AFMOK                       (1)
#define     LFS_BCR_AFMINOP                     (2)
#define     LFS_BCR_AFMDEVICEDETECTED           (3)
#define     LFS_BCR_AFMUNKNOWN                  (4)

/* 错误码 */

#define LFS_ERR_BCR_BARCODEINVALID              (-(BCR_SERVICE_OFFSET + 0))
#define LFS_ERR_BCR_INVALID_PORT                (-(BCR_SERVICE_OFFSET + 1))
#define LFS_ERR_BCR_POWERSAVETOOSHORT           (-(BCR_SERVICE_OFFSET + 2))
#define LFS_ERR_BCR_COMMANDUNSUPP               (-(BCR_SERVICE_OFFSET + 3))
#define LFS_ERR_BCR_SYNCHRONIZEUNSUPP           (-(BCR_SERVICE_OFFSET + 4))


/*=================================================================*/
/* 信息指令结构体 */
/*=================================================================*/
typedef struct _lfs_bcr_status
{
    WORD             device;
    WORD             bcr_scanner;
    DWORD            guid_lights[LFS_BCR_GUIDLIGHTS_SIZE];
    LPSTR            extra;
    WORD             device_position;
    USHORT           power_save_recovery_time;
    WORD             anti_fraud_module;
} LFSBCRSTATUS, *LPLFSBCRSTATUS;

typedef struct _lfs_bcr_caps
{
    WORD             dev_class;
    BOOL             compound;
    BOOL             can_filter_symbologies;
    LPWORD           symbologies;
    DWORD            guid_lights[LFS_BCR_GUIDLIGHTS_SIZE];
    LPSTR            extra;
    BOOL             power_save_control;
    BOOL             anti_fraud_module;
    LPDWORD          synchronizable_commands;
} LFSBCRCAPS, *LPLFSBCRCAPS;

/*=================================================================*/
/* 执行指令结构体 */
/*=================================================================*/
typedef struct _lfs_bcr_hex_data
{
    USHORT           length;
    LPBYTE           data;
} LFSBCRXDATA, *LPLFSBCRXDATA;

typedef struct _lfs_bcr_read_input
{
    LPWORD           symbologies;
} LFSBCRREADINPUT, *LPLFSBCRREADINPUT;

typedef struct _lfs_bcr_read_output
{
    WORD             symbology;
    LPLFSBCRXDATA    barcode_data;
    LPSTR            symbology_name;
} LFSBCRREADOUTPUT, *LPLFSBCRREADOUTPUT;

typedef struct _lfs_bcr_set_guidlight
{
    WORD             guid_light;
    DWORD            command;
} LFSBCRSETGUIDLIGHT, *LPLFSBCRSETGUIDLIGHT;

typedef struct _lfs_bcr_power_save_control
{
    USHORT           max_power_save_recovery_time;
} LFSBCRPOWERSAVECONTROL, *LPLFSBCRPOWERSAVECONTROL;

typedef struct _lfs_bcr_synchronize_command
{
    DWORD           command;
    LPVOID          cmd_data;
} LFSBCRSYNCHRONIZECOMMAND, *LPLFSBCRSYNCHRONIZECOMMAND;

/*=================================================================*/
/* 事件结构体 */
/*=================================================================*/

typedef struct _lfs_bcr_device_position
{
    WORD             position;
} LFSBCRDEVICEPOSITION, *LPLFSBCRDEVICEPOSITION;

typedef struct _lfs_bcr_power_save_change
{
    USHORT           power_save_recovery_time;
} LFSBCRPOWERSAVECHANGE, *LPLFSBCRPOWERSAVECHANGE;

/*   恢复原有字节对齐方式   */
#pragma pack(pop)
#ifdef __cplusplus
} /*extern "C"*/

#endif
#endif /* __INC_LFSBCR__H */
